<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table {
            text-align: center;
            line-height: 44px;
            height: 44px;
            border: 1px solid black;
        }
        
        thead {
            background-color: #ccc;
        }
        
        tr {
            border: 1px solid black;
        }
    </style>
</head>

<body>



    <script>
        let sales = [{
            name: '小明',
            age: 18,
            gender: '男',
            money: 30,
            status: 0
        }, {
            name: '小红',
            age: 26,
            gender: '女',
            money: 99,
            status: 3
        }, {
            name: '小刚',
            age: 19,
            gender: '男',
            money: 88,
            status: 2
        }, {
            name: '小丽',
            age: 20,
            gender: '女',
            money: 67,
            status: 1
        }, {
            name: '晓强',
            age: 23,
            gender: '女',
            money: 77,
            status: 1
        }, {
            name: '小张',
            age: 25,
            gender: '女',
            money: 80,
            status: 2
        }, ]
        sales.sort(function(a, b) {
            return b.money - a.money
        });

        console.log(sales);
        let html = ``
        html += `<table>
        <thead>
            <tr>
                <th>名次</th>
                <th>姓名</th>
                <th>年纪</th>
                <th>性别</th>
                <th>销售额</th>
                <th>业绩状态</th>
            </tr>
        </thead>
        <tbody>`
            // 字段 status 是销售状态 0:代表 未及格 1: 代表 及格 2: 代表 良好 3: 代表 优秀sales[i].status
        let str = []
        for (let i = 0; i < sales.length; i++) {
            if (sales[i].status === 1) {
                str[i] = '及格'
            }
            if (sales[i].status === 0) {
                str[i] = '不及格'
            }
            if (sales[i].status === 2) {
                str[i] = '良好'
            }
            if (sales[i].status === 3) {
                str[i] = '优秀'
            }
        }
        for (let i = 0; i < sales.length; i++) {
            html += `<tr>
                <td>${i+1}</td>
                <td>${sales[i].name}</td>
                <td>${sales[i].age}</td>
                <td>${sales[i].gender}</td>
                <td>${sales[i].money}</td>
                <td>${str[i]}</td>
            </tr>`
        }
        html += `</tbody>
              </table>`
        document.write(html);
    </script>
</body>

</html>